<template>
  <div class="app-container">
    <div class="title">{{ $t('good.商品信息') }}</div>
    <el-form ref="ruleFormRef" style="max-width: 100%" :model="ruleForm" :rules="rules" label-width="auto"
      label-position="left" class="demo-ruleForm" status-icon>
      <el-row :gutter="20" class="el-row">
        <el-col :span="12" :xs="24">
          <el-form-item :label="$t('good.商品分类')" prop="Level1Class" >
            <el-select v-model="ruleForm.Level1Class" :disabled="xqstate == 0 ? true : false" :placeholder="$t('good.请选择商品分类')"
              @change="Level1Classchange">
              <el-option v-for="item in Level1ClassList" :key="item.id" :label="item[CL('name')]" :value="item.id" />
            </el-select>
          </el-form-item>
          <el-form-item :label="$t('good.商品名称')" prop="name">
            <el-input v-model="ruleForm.name" :disabled="xqstate == 0 ? true : false" maxlength="50"
              :placeholder="$t('good.请输入商品名称')" />
          </el-form-item>
          <el-form-item :label="$t('good.数量单位')" prop="sldw">
            <el-select v-model="ruleForm.sldw" :disabled="xqstate == 0 ? true : false"
              :placeholder="$t('good.数量单位')">
              <el-option  v-for="item,index in allUnitslist" :key="index" :label="item[CL('name')]" :value="item[CL('name')]"  />
            </el-select>
          </el-form-item>
          <el-form-item :label="$t('good.单品重量')" prop="weight">
            <el-input v-model="ruleForm.weight" type="number" min="1" :disabled="xqstate == 0 ? true : false"
              :placeholder="$t('good.输入（kg）')" />
          </el-form-item>
          <!-- <el-form-item :label="$t('good.单品密度')" prop="midu" v-if="ruleForm.midu">
            <el-input v-model="ruleForm.midu" :disabled="true"
              :placeholder="$t('good.输入（Kg/m³）')" />
          </el-form-item> -->
          <el-form-item :label="$t('good.商品颜色')" prop="pro_color">
            <el-input v-model="ruleForm.pro_color"  :disabled="xqstate == 0 ? true : false"
              :placeholder="$t('good.请输入商品颜色')" />
          </el-form-item>
          <el-form-item :label="$t('good.货物类型')" prop="hwlx">
            <el-select v-model="ruleForm.hwlx" :disabled="xqstate == 0 ? true : false"
              :placeholder="$t('good.货物类型')">
              <el-option  v-for="item,index in hwlxList" :key="index" :label="item[CL('name')]" :value="item[CL('name')]"  />
              <!-- <el-option label="中国货物" value="Китайские товары" />
              <el-option label="俄罗斯货物" value="Российский груз" />
              <el-option label="在中俄物" value="В России" />
              <el-option label="在俄中物" value="В России" /> -->
            </el-select>
          </el-form-item>
              <!-- 单位 -->
          <el-form-item :label="$t('good.货币单位')" prop="currency">
            <el-select v-model="ruleForm.currency" :disabled="xqstate == 0 ? true : false"
              :placeholder="$t('good.货币单位')">
              <el-option  v-for="item,index in huobiDanwei" :key="index" :label="item[CL('name')]" :value="item.symbol"  />
            </el-select>
          </el-form-item>
          <el-form-item :label="$t('good.单价(含增值税发票)')" prop="sell_price">
            <el-input v-model="ruleForm.sell_price" type="number"  min="1" :disabled="xqstate == 0 ? true : false"
              :placeholder="$t('good.请输入商品单价')">
              <template #suffix>
                <!-- <span>{{ $t('common.元') }}</span> -->
              </template></el-input>
          </el-form-item>




          <el-form-item :label="$t('good.起卖数量')" prop="limit_start">
            <el-input v-model="ruleForm.limit_start" maxlength="10" min="1" @input="handleInput('limit_start')" :disabled="xqstate == 0 ? true : false" type="number"
               :placeholder="$t('good.请输入起卖数量')" />
          </el-form-item>
          <el-form-item :label="$t('good.批发价格')" prop="pf_price">
            <el-input v-model="ruleForm.pf_price" min="1" maxlength="10"  @input="handleInput('pf_price')"  :disabled="xqstate == 0 ? true : false" type="number"
              :placeholder="$t('good.请输入批发价格')"> <template #suffix>
                <!-- <span>{{ $t('common.元') }}</span> -->
              </template></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12" :xs="24">
          <el-form-item :label="$t('good.二级分类')" prop="cid">
            <el-select v-model="ruleForm.cid" :disabled="xqstate == 0 ? true : false" :placeholder="$t('good.请选择二级分类')"
              @change="cidChange">
              <el-option v-for="item in Level2ClassList" :key="item.id" :label="item[CL('name')]" :value="item.id" />
            </el-select>
          </el-form-item>
          <el-form-item :label="$t('good.商品品牌')" prop="brand">
            <el-input v-model="ruleForm.brand" :disabled="xqstate == 0 ? true : false" maxlength="50"
              :placeholder="$t('good.请输入商品品牌')" />
          </el-form-item>
          <el-form-item :label="$t('good.总库存')" prop="stock">
            <el-input v-model="ruleForm.stock" @input="handleInput('stock')" min="1" :disabled="xqstate == 0 ? true : false" type="number" maxlength="8"
              :placeholder="$t('good.请输入库存数量')" />
          </el-form-item>
          <el-form-item :label="$t('good.单品体积')" prop="volume">
            <el-input v-model="ruleForm.volume" type="number" min="1" :disabled="xqstate == 0 ? true : false"
              :placeholder="$t('good.输入（m³）')" />
          </el-form-item>
          <el-form-item :label="$t('good.发货地址')" prop="fhdz">
            <el-select v-model="ruleForm.fhdz" :disabled="xqstate == 0 ? true : false" :placeholder="$t('good.发货地址')">
              <el-option v-for="item, index in addressList" :key="index" :label="item" :value="item" />
            </el-select>
          </el-form-item>
          <!-- <el-form-item :label="$t('good.运费')" prop="is_yf">
            <el-select v-model="ruleForm.is_yf" :disabled="xqstate == 0 ? true : false" :placeholder="$t('good.运费')">
              <el-option :label="$t('good.不包含')" :value="0" />
              <el-option :label="$t('good.包含')" :value="1" />
            </el-select>
          </el-form-item> -->
          <!-- <el-form-item :label="$t('good.单价(含增值税发票)')" prop="sell_price_ru">
            <el-input v-model="ruleForm.sell_price_ru" type="number" min="1" :disabled="xqstate == 0 ? true : false"
              :placeholder="$t('good.请输入商品单价（实时汇率 1元=100卢布）')"> <template #suffix>
                <span>{{ $t('common.卢布') }}</span>
              </template></el-input>
          </el-form-item> -->
          <el-form-item :label="$t('good.起批数量')" prop="qpsl">
            <el-input v-model="ruleForm.qpsl" min="1" :maxlength="10" @input="handleInput('qpsl')"  :disabled="xqstate == 0 ? true : false" type="number" :placeholder="$t('good.请输入起批数量')" />
          </el-form-item>
          <!-- <el-form-item :label="$t('good.批发价格')" prop="pf_price_ru">
            <el-input v-model="ruleForm.pf_price_ru" :maxlength="10" min="1" @input="handleInput('pf_price_ru')" :disabled="xqstate == 0 ? true : false" type="number"
              :placeholder="$t('good.请输入商品单价（实时汇率 1元=100卢布）')"> <template #suffix>
                <span>{{ $t('common.卢布') }}</span>
              </template></el-input>
          </el-form-item> -->
        </el-col>
      </el-row>
      <el-row :gutter="20" class="el-row">
        <el-col :span="24">
          <el-form-item :label="$t('good.商品规格')" prop="productSpecifications">
            <!-- <el-input v-model="input" style="width: 240px" :placeholder="Please input" /> -->
            <div>
              <el-input v-model="ggName1" class="widt120" :disabled="xqstate == 0 ? true : false"
                :placeholder="$t('good.自定义参数名称')" />
              <el-input v-model="ggValue1" class="widt120" :disabled="xqstate == 0 ? true : false"
                :placeholder="$t('good.自定义参数值')" />
            </div>
            <div v-if="customizeggList.includes(1)">
              <el-input v-model="ggName2" class="widt120" :disabled="xqstate == 0 ? true : false"
                :placeholder="$t('good.自定义参数名称')" />
              <el-input v-model="ggValue2" class="widt120" :disabled="xqstate == 0 ? true : false"
                :placeholder="$t('good.自定义参数值')" />
            </div>
            <div v-if="customizeggList.includes(2)">
              <el-input v-model="ggName3" :disabled="xqstate == 0 ? true : false" class="widt120"
                :placeholder="$t('good.自定义参数名称')" />
              <el-input v-model="ggValue3" :disabled="xqstate == 0 ? true : false" class="widt120"
                :placeholder="$t('good.自定义参数值')" />
            </div>
            <div v-if="customizeggList.includes(3)">
              <el-input v-model="ggName4" :disabled="xqstate == 0 ? true : false" class="widt120"
                :placeholder="$t('good.自定义参数名称')" />
              <el-input v-model="ggValue4" :disabled="xqstate == 0 ? true : false" class="widt120"
                :placeholder="$t('good.自定义参数值')" />
            </div>
            <div v-if="customizeggList.includes(4)">
              <el-input v-model="ggName5" :disabled="xqstate == 0 ? true : false" class="widt120"
                :placeholder="$t('good.自定义参数名称')" />
              <el-input v-model="ggValue5" :disabled="xqstate == 0 ? true : false" class="widt120"
                :placeholder="$t('good.自定义参数值')" />
            </div>
            <el-button @click="addcustomizegg()" v-if="xqstate == 0 || customizeggList.length>=5 ? false : true">{{ $t('good.+自定义规格（5条）')
              }}</el-button>
          </el-form-item>
          <el-form-item :label="$t('good.商品简介')" prop="detail">
            <el-input v-model="ruleForm.detail" :disabled="xqstate == 0 ? true : false" maxlength="200" type="textarea"
              :rows="4" :placeholder="$t('good.请输入商品简介（200字以内）')" />
          </el-form-item>

          <el-form-item prop="video" class="margin20">
            <div slot="label" class="label">
              <div class="hei"><span class="reds"> * </span>{{ $t('good.上传视频') }}</div>
              <div class="wenjian">{{ $t('merchantInfo.支持mp4、mvb、AVI格式大小限制在35m内') }}</div>
            </div>
            <upload :limit="4" :fieldType="'video'" :acceptType="'.mp4, .avi, .mvb'" :type="'video'" :videoUrl="videoList" @UserFileUrl="UserFileUrl">
            </upload>
          </el-form-item>
          <el-form-item prop="jj_video" class="margin20">
            <div slot="label" class="label">
              <div class="hei"><span class="reds"> * </span>{{ $t('good.上传商品讲解视频') }}</div>
              <div class="wenjian">{{ $t('merchantInfo.支持mp4、mvb、AVI格式大小限制在35m内') }}</div>
            </div>
            <upload  :fieldType="'jj_video'" :type="'video'" :videoUrl="videoListjj_video"
              @UserFileUrl="UserFileUrl" :acceptType="'.mp4, .avi, .mvb'"   @DeleterFile="DeleterFile"></upload>
          </el-form-item>
          <el-form-item prop="pics" class="margin20">
            <div slot="label" class="label2">
              <div class="hei"><span class="reds"> * </span>{{ $t('good.上传商品主图(中文)') }}</div>
              <div class="wenjian">{{ $t('good.支持jpg、jpeg、png格式 最多上传6张 大小单张限制到7m内') }}</div>
            </div>
            <upload :limit="6" :fieldType="'pics'" :removestate="xqstate" :fileLists="fieldListpics"
              @UserFileUrl="UserFileUrl" :acceptType="'.jpg, .jpeg, .png'" @DeleterFile="DeleterFile"></upload>
          </el-form-item>
          <el-form-item prop="pics_ru" class="margin20">
            <div slot="label" class="label2">
              <div class="hei"><span class="reds"> * </span>{{ $t('good.上传商品主图(俄文)') }}</div>
              <div class="wenjian">{{ $t('good.支持jpg、jpeg、png格式 最多上传6张 大小单张限制到7m内') }}</div>
            </div>
            <upload :limit="6" :fieldType="'pics_ru'" :removestate="xqstate" :fileLists="fieldListpics_ru"
              @UserFileUrl="UserFileUrl" :acceptType="'.jpg, .jpeg, .png'" @DeleterFile="DeleterFile"></upload>
          </el-form-item>
          <el-form-item prop="xq_pics" class="margin20">
            <div slot="label" class="label2">
              <div class="hei"><span class="reds"> * </span>{{ $t('good.上传商品详情图(中文)') }}</div>
              <div class="wenjian">{{ $t('good.支持jpg、jpeg、png格式 最多上传6张 大小单张限制到7m内') }}</div>
            </div>
            <upload :limit="6" :fieldType="'xq_pics'" :acceptType="'.jpg, .jpeg, .png'" :removestate="xqstate" :fileLists="fieldListxq_pics"
              @UserFileUrl="UserFileUrl"   @DeleterFile="DeleterFile"></upload>
          </el-form-item>
          <el-form-item prop="xq_pics_ru" class="margin20">
            <div slot="label" class="label2">
              <div class="hei"><span class="reds"> * </span>{{ $t('good.上传商品详情图(俄文)') }}</div>
              <div class="wenjian">{{ $t('good.支持jpg、jpeg、png格式 最多上传6张 大小单张限制到7m内') }}</div>
            </div>
            <upload :limit="6" :fieldType="'xq_pics_ru'" :removestate="xqstate" :fileLists="fieldListxq_pics_ru"
              @UserFileUrl="UserFileUrl"  :acceptType="'.jpg, .jpeg, .png'" @DeleterFile="DeleterFile"></upload>
          </el-form-item>
          <el-form-item prop="3D" class="margin20">
            <div slot="label" class="label2">
              <div class="hei">{{ $t('good.上传3D商品文件') }}</div>
              <div class="wenjian">{{ $t('good.支持dae、glb格式 最多上传3张 大小单张限制到100m内') }}</div>
            </div>
            <upload :limit="3" :fieldType="'3D'" type="3d" :removestate="xqstate" :fileLists="fieldList3D"
              @UserFileUrl="UserFileUrl" :acceptType="'.glb,.dae'"  @DeleterFile="DeleterFile" >
            </upload>
          </el-form-item>
          <el-form-item  class="margin20">
            <div slot="label" class="label2">
              <div class="hei">{{ $t('good.上传3D商品缩略图') }}</div>
              <div class="wenjian">{{ $t('good.支持jpg、jpeg、png格式 最多上传3张 大小单张限制到7m内') }}</div>
            </div>
            <upload :limit="3" :fieldType="'sd_pic'"  :removestate="xqstate" :fileLists="fieldListsd_pic"
              @UserFileUrl="UserFileUrl" :acceptType="'.jpg, .jpeg, .png'"   @DeleterFile="DeleterFile" >
            </upload>
          </el-form-item>
        </el-col>
      </el-row>
      <!-- 添加商品其它规格 -->
      <otherGoodSpecificationss  v-if="otherGoodSpecificationssStste"  :editOrViewStatus="editOrViewStatus" :otherDetailList="otherDetailList"
        ref="otherGoodSpecifications" @getspecificationsForm="getspecificationsForm"></otherGoodSpecificationss>

      <!-- <div class="fix" style="margin-top: 40px;">
        <div style="margin-right: 10px;">
          {{ $t('good.商品置顶') }}
          <el-switch v-model="ruleForm.zhiding" class="ml-2" :active-value="1" :inactive-value="0"
            :disabled="xqstate == 0 ? true : false"
            @click="onSwitchChangeStatus"
            style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949" />
        </div>
        <div style="margin-right: 10px;">
          {{ $t('good.营销活动') }}
          <el-switch v-model="ruleForm.gid" active-value="4" inactive-value="0" class="ml-2"
            :disabled="xqstate == 0 ? true : false"
            style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949" />
        </div>
        <div>
          {{ $t('good.折扣') }}
          <el-input-number class="my-el-input-number" @change="handleChange"  :step="10" v-model="ruleForm.huodong" :min="10" :max="90" :disabled="xqstate == 0 ? true : false" size="large" />

        </div>

      </div> -->
      <el-form-item style="float: right; margin: 40px 40px 0 0;">
        <div class="right-aligned">
          <!-- <el-button @click="qx">{{ $t('good.取消') }}</el-button> -->
          <!-- <el-button type="warning" @click="translate">
            {{ $t('good.中文转俄文') }}
          </el-button> -->
          <el-button type="success" @click="addGood(ruleFormRef, '1')" v-if="xqstate == 0 || xqstate == 1 || xqstate == 3 ? false : true">
            {{ $t('good.存为草稿') }}
          </el-button>
          <el-button type="primary" @click="addGood(ruleFormRef, '0')" v-if="xqstate == 0 || xqstate == 3 ? false : true">
            {{xqstate==1 ? $t('shop.修改商品'): $t('good.发布商品') }}
          </el-button>
          <el-button type="primary" @click="addGood(ruleFormRef, '0')" v-if=" xqstate == 3 ? true : false">
            {{ $t('shop.重新上架') }}
          </el-button>
        </div>
      </el-form-item>
    </el-form>
    <fbDialog v-if="fbDialogss" :paymentObj="paymentObj" :isState="xqstate" @confirmRelease="submitAddGood"
      @closeDialogVisible="closeDialogVisible"></fbDialog>
  </div>
</template>

<script setup lang="ts">
import upload from "@@/components/Upload/index.vue"
import otherGoodSpecificationss from "./components/otherGoodSpecifications.vue"
import fbDialog from "./components/fbDialog.vue"
import type { GoodsInfo, GoodsOtherInfo } from "@@/apis/good/type"
import { cloneDeep } from "lodash-es"
import { useUserStore } from "@/pinia/stores/user"
import { getAddGoodsinfo, getLevel1Classification,topUp, getLevel2Classification, getBus_address, getGoodDetails, getGoodDraft, getGoodTranslate,setst } from "@@/apis/good"
import { inject } from 'vue'
const CL: any = inject("$CL");
import { useI18n } from 'vue-i18n';
import { FormInstance } from "element-plus"
const { locale, t } = useI18n();//登录国籍
const router = useRouter()
const route = useRoute();
const userStore = useUserStore()
const isIndeterminate = ref(true)
const fbDialogss = ref(false)
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
import { getCurrentUnit } from '@/common/utils/pricetag';

const formSize = ref('default')
const otherGoodSpecifications = ref<InstanceType<typeof otherGoodSpecificationss>>(); // 存储子组件实例引用
const DEFAULT_FORM_DATA: GoodsInfo = {
  Level1Class:'',
  cid: '',//商品分类
  name: '',//商品名称
  sell_price: '',
  pf_price: '',
  pro_color: '',//产品颜色
  sldw: '',//数量单位
  weight: '',//单品重量
  currency: '', //货币单位
  midu: '',//单品密度
  hwlx: '',//货物类型
  limit_start: '',//起卖数量
  pf_price_ru: '',
  levelTwoClass: '',
  brand: '',
  stock: '',
  volume: '',
  fhdz: '',
  is_yf: 0,
  sell_price_ru: '',
  qpsl: '',
  productSpecifications: '',
  detail: '',
  video: '',
  jj_video: '',
  pics: '',
  pics_ru: '',
  xq_pics: '',
  xq_pics_ru: '',
  sd_pic: '',
  '3D': '',
  // gid: '0',
  // zhiding: '0',
  // huodong: 10,
  locale: locale.value,
  is_cg: '0',
  params: "",
}
const lang = localStorage.getItem('country');
const xqstate = ref(Number(route.query.state))
const otherGoodSpecificationssStste = ref(true)

const otherDetailList = ref()
const editOrViewStatus = ref(Number(route.query.state))
const queryId = ref(route.query.id);
// const allUnitslist = ref(['个','箱','套','千克','瓶','包','米','平方米','双','盒','卷','袋','升','辆','立方米','片','桶','厘米','吨','台']);
const allUnitslist = ref([{
  name:"个",
  name_ru:'шт',
},{
  name:"箱",
  name_ru:'ящик',
},{
  name:"套",
  name_ru:'комплект',
},{
  name:"千克",
  name_ru:'кг',
},{
  name:"瓶",
  name_ru:'бут',
},{
  name:"包",
  name_ru:'сумка',
},{
  name:"米",
  name_ru:'м',
},{
  name:"平方米",
  name_ru:'㎡',
},{
  name:"双",
  name_ru:'пара',
},{
  name:"盒",
  name_ru:'коробка',
},{
  name:"卷",
  name_ru:'рулон',
},{
  name:"袋",
  name_ru:'мешок',
},{
  name:"升",
  name_ru:'литр',
},{
  name:"辆",
  name_ru:'шт',
},{
  name:"立方米",
  name_ru:'m³',
},{
  name:"片",
  name_ru:'лист',
},{
  name:"桶",
  name_ru:'канистры',
},{
  name:"厘米",
  name_ru:'см',
},{
  name:"吨",
  name_ru:'т',
},{
  name:"台",
  name_ru:'шт',
},]);

const hwlxList = ref([{
  name:"中国货物",
  name_ru:'Китайские товары',
},{
  name:"俄罗斯货物",
  name_ru:'Русские товары',
},{
  name:"在中俄物",
  name_ru:'Русские товары в Китае',
},{
  name:"在俄中物",
  name_ru:'Китайские товары в России',
}])

// 货币单位
const huobiDanwei = ref(getCurrentUnit())


const cidhuixian = ref()
const tagType = ref('primary')
const tagEffect = ref('plain')
const ruleFormRef = ref()
const ruleForm = ref<GoodsInfo>(cloneDeep(DEFAULT_FORM_DATA))
const rules = {
  cid: [{ required: true, message: t('good.商品分类') + t('merchantInfo.不能为空'), trigger: 'change' },],
  Level1Class: [{ required: true, message: t('good.商品分类') + t('merchantInfo.不能为空'), trigger: 'change' },],
  name: [{ required: true, message: t('good.请输入商品名称'), trigger: 'blur' },],
  sldw: [{ required: true, message: t('good.数量单位'), trigger: 'change' },],
  weight: [{ required: true, message: t('good.输入（kg）'), trigger: 'blur' },],
  currency: [{ required: true, message: t('good.货币单位'), trigger: 'change' },],
  // midu: [{ required: true, message: t('good.输入（Kg/m³）'), trigger: 'blur' },],
  pro_color: [{ required: true, message: t('good.请输入商品颜色'), trigger: 'blur' },],
  hwlx: [{ required: true, message: t('good.货物类型'), trigger: 'change' },],
  sell_price: [{ required: true, message: t('good.请输入商品单价'), trigger: 'blur' },],
  // sell_price_ru: [{ required: true, message: t('good.请输入商品单价'), trigger: 'blur' },],
  limit_start: [{ required: true, message: t('good.请输入起卖数量'), trigger: 'blur' },],
  qpsl: [{ required: true, message: t('good.请输入起批数量'), trigger: 'blur' },],
  pf_price: [{ required: true, message: t('good.请输入商品单价'), trigger: 'blur' },],
  // pf_price_ru: [{ required: true, message: t('good.请输入商品单价（实时汇率 1元=100卢布）'), trigger: 'blur' },],
  levelTwoClass: [{ required: true, message: t('good.请选择二级分类'), trigger: 'blur' },],
  brand: [{ required: true, message: t('good.请输入商品品牌'), trigger: 'blur' },],
  stock: [{ required: true, message: t('good.请输入库存数量'), trigger: 'blur' },],
  volume: [{ required: true, message: t('good.输入（m³）'), trigger: 'blur' },],
  fhdz: [{ required: true, message: t('good.发货地址'), trigger: 'change' },],
  is_yf: [{ required: true, message:  t('good.运费'), trigger: 'change' },],
  detail: [{ required: true, message: t('good.请输入商品简介（200字以内）'), trigger: 'blur' },],
  video: [{ required: true, message: t('good.上传商品讲解视频'), trigger: 'change' },],
  jj_video: [{ required: true, message: t('good.上传商品讲解视频'), trigger: 'change' },],
  pics: [{ required: true, message: t('good.上传商品主图(中文)'), trigger: 'change' },],
  pics_ru: [{ required: true, message: t('good.上传商品主图(俄文)'), trigger: 'change' },],
  xq_pics: [{ required: true, message: t('good.上传商品详情图(中文)'), trigger: 'change' },],
  xq_pics_ru: [{ required: true, message: t('good.上传商品详情图(俄文)'), trigger: 'change' },],
  '3D': [{ required: false, message: t('good.上传3D商品文件'), trigger: 'blur' },],
}
const locationOptions = ['Home', 'Company', 'School']
const SpecificationsFormstate=ref(false)//判断规格数据正则状态
const specificationsForm = ref<Array<object>>([]);
const getspecificationsForm = (valuearr: Array<Object>,state:Number) => {
  if(state){
    if(locale.value=='ru'){
     //处理ru国籍部分传参
      valuearr.forEach(item => {
        // 修改键名
        item.name_ru = item.name;
        item.params_ru = item.params;
        item.pro_color_ru = item.pro_color;


        delete item.name;
        delete item.pro_color;
        delete item.params;
        });
      }
    SpecificationsFormstate.value=true
    specificationsForm.value = valuearr
    console.log(specificationsForm.value,'处理之后specificationsForm.value');


  }

}
const Level1ClassList = ref([
  {
    id: 1,
    pid: 0,
    name: t('common.暂无数据'),
    name_ru: 'Нет данных'
  }
])
const Level2ClassList = ref([
  {
    id: 1,
    pid: 0,
    name: t('common.暂无数据'),
    name_ru: 'Нет данных'
  }
])
const addressList = ref([
])
const Level1Class = ref<number>()
//二级商品分类
const getClassification = () => {
  getLevel1Classification().then((res: any) => {
    if (res.code == 1) {
      Level1ClassList.value = res.data.filter(item => item.name != '俄货专区' && item.name != 'GLUZ自营商品')
    }
  }).finally(() => {
    // loading.value = false
  })


}
//  // 自定义校验规则：不允许负数和小数
// const validateNumber = (rule, value, callback) => {
//   const reg = /^[0-9]+$/; // 只允许正整数
//     if (!value) {
//       callback(new Error('请输入数字'));
//     } else if (!reg.test(value)) {
//       callback(new Error('只能输入正整数'));
//     } else {
//       callback();  // 校验通过
//     }
// }
let indexsss = 0
//一级商品分类
const Level1Classchange = (value: any) => {
  ruleForm.value.cid = ""
  if (!value) return;
  getLevel2Classification({ pid: value }).then((res: any) => {
    if (res.code == 1) {
      Level2ClassList.value = res.data
      if (cidhuixian.value && indexsss == 0) {
        indexsss = 1
        ruleForm.value.cid = cidhuixian.value
      }
    }
  }).finally(() => {
    // loading.value = false
  })
}
const Bus_address = () => {
  getBus_address({ bid: localStorage.getItem('bid'),locale:locale.value }).then((res: any) => {
    if (res.code == 1) {
      res.data = res.data.filter((ele:string)=> {
        return ele != '';
      })
      addressList.value = res.data
    }
  }).finally(() => {
    // loading.value = false
  })
}
const cidall = ref()
const cidChange = (value: any) => {
  // cidall.value=Level1Class.value+','+value
}
getClassification()
Bus_address()
// 自定义规格
const customizeggList = ref<Array<number>>([])
let ggindex = 0
const ggName1 = ref('')
const ggValue1 = ref('')
const ggName2 = ref('')
const ggValue2 = ref('')
const ggName3 = ref('')
const ggValue3 = ref('')
const ggName4 = ref('')
const ggValue4 = ref('')
const ggName5 = ref('')
const ggValue5 = ref('')
const addcustomizegg = () => {
  if (ggindex == 5) return
  if (ggindex == 0 && !ggName1.value) {
    ElMessage({
      message: t('common.自定义参数名称不能为空'),
      type: 'warning',
    })
    return false
  } else if (ggindex == 1 && !ggName2.value) {
    ElMessage({
      message: t('common.自定义参数名称不能为空'),
      type: 'warning',
    })
    return false
  } else if (ggindex == 2 && !ggName3.value) {
    ElMessage({
      message: t('common.自定义参数名称不能为空'),
      type: 'warning',
    })
    return false
  } else if (ggindex == 3 && !ggName4.value) {
    ElMessage({
      message: t('common.自定义参数名称不能为空'),
      type: 'warning',
    })
    return false
  } else if (ggindex == 4 && !ggName5.value) {
    ElMessage({
      message: t('common.自定义参数名称不能为空'),
      type: 'warning',
    })
    return false
  }
  ggindex++
  customizeggList.value.push(ggindex)
}
// const allowedValues=ref([10, 20, 30, 40,50,60,70,80,90])
// const  handleChange=(newValue)=> {
//       // 如果输入的值不是允许的数字之一，重置为 null
//       if (!allowedValues.value.includes(newValue)) {
//         ElMessage({
//           message: '请输入允许的数字：10, 20, 30, 40,50,60,70,80,90',
//           type: 'warning',
//         })
//         ruleForm.value.huodong = 10; // 或者设置为某个默认值
//       }
// }
//处理自定义规格数据
const ggchuli = () => {
  let str = "";
  if (ggName1.value && ggValue1.value) {
    str = ggName1.value + ':' + ggValue1.value;
  }
  if (ggName2.value && ggValue2.value) {
    str = str + "," + ggName2.value + ':' + ggValue2.value;
  }
  if (ggName3.value && ggValue3.value) {
    str = str + "," + ggName3.value + ':' + ggValue3.value;
  }
  if (ggName4.value && ggValue4.value) {
    str = str + "," + ggName4.value + ':' + ggValue4.value;
  }
  return str;
}
// 计算图片数量
const countPicNum = (val: any) => {
  let nowNum = 0;
  let country = localStorage.getItem('country');
  if (country === "ru") {
    if (val.pics_ru) {
      nowNum = Math.round(nowNum + val.pics_ru.split(",").length);
    }
    if (val.xq_pics_ru) {
      nowNum = Math.round(nowNum + val.xq_pics_ru.split(",").length);
    }
  } else {
    if (val.pics) {
      nowNum = Math.round(nowNum + val.pics.split(",").length);
    }

    if (val.xq_pics) {
      nowNum = Math.round(nowNum + val.xq_pics.split(",").length);
    }
  }
  return nowNum;
}

let paymentObj = ref<object>({});

let obj = ref()
let ruleForm_ru=ref()
const addGood = async (formEl: FormInstance | undefined, iscgstate: string) => {

  if (otherGoodSpecifications.value) {
    otherGoodSpecifications.value.addggGood(iscgstate);
  }
  // debugger
  //重新上架逻辑
 if(xqstate.value==3){
  if(ruleForm.value.detail==''){
    ElMessage({
    message: t('good.请您重新填写商品简介！！！！'),
    type: 'warning',
    plain: true,
    })
    return false
  }
 }
 if(ruleForm.value.sd_pic && !ruleForm.value['3D']){
        ElMessage({
        message: t('good.上传3D商品文件'),
        type: 'warning',
      })
      return false
  }
  if(!ruleForm.value.sd_pic && ruleForm.value['3D']){
      ElMessage({
      message: t('good.请上传3D商品缩略图'),
      type: 'warning',
      })
      return false
  }

  // return false
  ruleForm.value.is_cg = iscgstate

  ruleForm.value.params = ggchuli()
  console.log('iscgstate==============', iscgstate)
  //上架状态
  if (iscgstate == "0") {
    let picNum = countPicNum(ruleForm.value);
    let videoNum = !!ruleForm.value.video ? 1 : 0;
    let jjVideoNum = !!ruleForm.value.jj_video ? 1 : 0;

    if (specificationsForm.value.length > 0) {
      specificationsForm.value.map((item: any) => {
        let newNum = countPicNum(item);
        let newVNum = !!item.video ? 1 : 0;
        let newJJVNum = !!item.jj_video ? 1 : 0;
        picNum = Math.round(picNum + newNum);
        videoNum = Math.round(videoNum + newVNum);
        jjVideoNum = Math.round(jjVideoNum + newJJVNum);
      })
    }
    paymentObj.value = {
      picNum: picNum,
      videoNum: videoNum,
      jjVideoNum: jjVideoNum,
    };
    if (!queryId.value) {
      confirmRelease("2");
    }
    await formEl.validate((valid: any, fields: any) => {
      if (!valid) {
        ElMessage.error(t('good.商品信息')+t('merchantInfo.不能为空'))
        return
      }
      if (valid) {
        ruleForm_ru.value=JSON.parse(JSON.stringify(ruleForm.value))
        //处理ru国籍部分传参
        let list=['name','brand','hwlx','params','pro_color','sldw','fhdz','detail']
        if(locale.value=='ru'){
          for (let key in ruleForm_ru.value) {
            list.forEach((item=>{
              if (key === item) {
                ruleForm_ru.value[key + '_ru'] = ruleForm_ru.value[key]; // 将值赋给新 key
                delete ruleForm_ru.value[key];        // 删除旧的 key
              }
            }))
          }
        }
        // console.log(ruleForm_ru.value,specificationsForm.value,'处理之后的数据');
        console.log(specificationsForm.value)

        for (let i = 0; i < specificationsForm.value.length; i++) {
          console.log(specificationsForm.value[i]); // 输出数组的每个元素
          if(specificationsForm.value[i].name==''||specificationsForm.value[i].pro_color==''||specificationsForm.value[i].stock==''
          ||specificationsForm.value[i].qpsl==''||specificationsForm.value[i].weight==''||specificationsForm.value[i].volume==''
          ||specificationsForm.value[i].sell_price==''||specificationsForm.value[i].midu==''
          ||specificationsForm.value[i].pf_price==''||specificationsForm.value[i].pic==''||specificationsForm.value[i].pic_ru==''||specificationsForm.value[i].video==''
          ||specificationsForm.value[i].jj_video==''){
            ElMessage.error(t('good.商品信息')+t('merchantInfo.不能为空'))
            return
          }
        }

        if(SpecificationsFormstate.value){
          fbDialogss.value = true
        }
      } else {
        console.log('error submit!', fields)
      }
    })
  } else {
    ruleForm_ru.value=JSON.parse(JSON.stringify(ruleForm.value))
        //处理ru国籍部分传参
        let list=['name','brand','hwlx','params','pro_color','sldw','fhdz','detail']
        if(locale.value=='ru'){
          for (let key in ruleForm_ru.value) {
            list.forEach((item=>{
              if (key === item) {
                ruleForm_ru.value[key + '_ru'] = ruleForm_ru.value[key]; // 将值赋给新 key
                delete ruleForm_ru.value[key];        // 删除旧的 key
              }
            }))
          }
        }
    confirmRelease("");
  }
}

const submitAddGood = async (val: any) => {
  let obj = {};
  switch (val.state) {
    case '0':
      ruleForm.value.status = '1';
      confirmRelease(ruleForm.value.status);
      break;
    case '1':
      if (queryId.value && ruleForm.value.is_cg !== "1") {
        if(locale.value=='ru'){
            obj = {
            info: { ...ruleForm_ru.value, id: queryId.value, status: val.state },
            option: specificationsForm.value
            }
        }else{
          obj = {
          info: { ...ruleForm.value, id: queryId.value, status: val.state },
          option: specificationsForm.value
        }
        }

      } else {
        if(locale.value=='ru'){
          obj = {
            info: { ...ruleForm_ru.value, status: ruleForm_ru.value.is_cg !== "1" ? val.state : "", id: queryId.value },
            option: specificationsForm.value,
          }
        }else{
          obj = {
            info: { ...ruleForm.value, status: ruleForm.value.is_cg !== "1" ? val.state : "", id: queryId.value },
            option: specificationsForm.value,
          }
        }
      }
      let res = await getGoodTranslate({
        proid: queryId.value,
        yf_points: val.payPoints,
        fwids: val.fwids,
        fwnames: val.fwnames,
        status: "1",
        type:'1',
        ...obj
      })
      if (res.code === 1) {
         ElMessage.success(t('common.操作成功'))
        ElMessageBox.alert(t('common.请等待平台确认，我们会尽快处理，谢谢提交申请成功'), {
          confirmButtonText: t('common.确认'),
          customClass: "new_box",
          callback: () => {
            router.back();
          },
        })
        if(xqstate.value==3){
          handleSetUp()
         }
      }

      break;

    default:
      break;
  }

}

const confirmRelease = (state: string) => {
  // debugger
  console.log("state=========", state)
  let obj={}
  if (queryId.value && ruleForm.value.is_cg !== "1") {
    if(locale.value=="ru"){
      obj = {
      info: { ...ruleForm_ru.value, id: queryId.value, status: state },
      option: specificationsForm.value,
      locale: lang
    }
    }else{
      obj = {
        info: { ...ruleForm.value, id: queryId.value, status: state },
        option: specificationsForm.value,
        locale: lang
      }
    }

  } else {
    if(ruleForm.value.is_cg !== "1"){
      if(locale.value=="ru"){
        obj = {
          info: { ...ruleForm_ru.value, status: state, id: queryId.value },
          option: specificationsForm.value,
        }
      }else{
        obj = {
          info: { ...ruleForm.value, status: state, id: queryId.value },
          option: specificationsForm.value,
        }
      }

    }else{
      if(locale.value=="ru"){
        obj = {
          info: { ...ruleForm_ru.value,id: queryId.value },
          option: specificationsForm.value,
        }
      }else{
        obj = {
          info: { ...ruleForm.value,id: queryId.value },
          option: specificationsForm.value,
        }
      }

    }
    // obj = {
    //   info: { ...ruleForm.value, status: ruleForm.value.is_cg !== "1" ? state : '', id: queryId.value },
    //   option: specificationsForm.value,
    // }
  }
  if(obj.info.volume){
    obj.info.midu =  ((obj.info.weight || 0) / (obj.info.volume)).toFixed(2)
  }
  // console.log(obj,'objobjobjobjobj',obj.info.volume / obj.info.weight)
  getAddGoodsinfo(obj).then((res: any) => {
    if (res.code == '1') {
      queryId.value = res.data;
      if(state === "2") return;
      if (ruleForm.value.is_cg == '1') {
        ElMessage.success(t('common.保存草稿成功'))
        router.back();
      } else {
        if(xqstate.value==3){
          handleSetUp()
        }else{
          // t('common.操作成功')
          ElMessageBox.alert(t('common.操作成功'), {
            confirmButtonText: t('common.确认'),
            customClass: "new_box",
            callback: () => {
              router.back();
            },
          })
        }
      }
    }

  }).finally(() => {
    // loading.value = false
  })
}
// 商品上架
const handleSetUp = () => {
  // ElMessageBox.confirm(proxy!.$t('shop.确认上架商品吗？'), proxy!.$t('shop.上架商品'), {
  //   confirmButtonText: proxy!.$t('common.确认'),
  //   cancelButtonText: proxy!.$t('common.取消'),
  //   customClass: "new_box",
  //   type: "warning"
  // }).then(() => {
  //   setst({
  //     // bid: row.bid,
  //     status: "1",
  //     // ids: ids.join(','),
  //     ids: queryId.value,
  //   }).then(() => {
  //     ElMessage.success("上架成功")
  //     // getTableData()
  //     router.back();

  //   })
  // }).catch(() => {

  // })
  setst({
      // bid: row.bid,
      status: "1",
      // ids: ids.join(','),
      ids: queryId.value,
    }).then(() => {
      ElMessage.success(t('shop.上架成功'))
      // getTableData()
      router.back();

    })
}
// 取消
const qx = () => {
  router.back();
}
// 取消
const closeDialogVisible = () => {
  fbDialogss.value = false
}
//文件上传返回不同字段类型
const UserFileUrl = (obj: any) => {
  let type = obj.type
  if (type == 'jj_video') {
    ruleForm.value.jj_video = obj.url
  } else if (type == 'pics') {
    if (ruleForm.value.pics) {
      ruleForm.value.pics = ruleForm.value.pics.concat(",", obj.url)
    } else {
      ruleForm.value.pics = obj.url
    }
  } else if (type == 'pics_ru') {
    if (ruleForm.value.pics_ru) {
      ruleForm.value.pics_ru = ruleForm.value.pics_ru.concat(",", obj.url)
    } else {
      ruleForm.value.pics_ru = obj.url
    }
  } else if (type == 'video') {
    ruleForm.value.video = obj.url
  } else if (type == 'xq_pics') {
    if (ruleForm.value.xq_pics) {
      ruleForm.value.xq_pics = ruleForm.value.xq_pics.concat(",", obj.url)
    } else {
      ruleForm.value.xq_pics = obj.url
    }
  } else if (type == 'sd_pic') {
    if (ruleForm.value.sd_pic) {
      ruleForm.value.sd_pic = ruleForm.value.sd_pic.concat(",", obj.url)
    } else {
      ruleForm.value.sd_pic = obj.url
    }
  }else if (type == 'xq_pics_ru') {
    if (ruleForm.value.xq_pics_ru) {
      ruleForm.value.xq_pics_ru = ruleForm.value.xq_pics_ru.concat(",", obj.url)
    } else {
      ruleForm.value.xq_pics_ru = obj.url
    }
  } else if (type == '3D') {
    if (ruleForm.value['3D']) {
      ruleForm.value['3D'] = ruleForm.value['3D'].concat(",", obj.url)
    } else {
      ruleForm.value['3D'] = obj.url
    }
  }
}
const DeleterFile = (obj: any) => {
  let type = obj.type
  let list=obj.deleterList
  console.log(obj.deleterList,'删除之后返回的图片数组');
  if (type == 'pics') {
    if (ruleForm.value.pics) {
      ruleForm.value.pics = list.map(item => item.response ? item.response.info.url : item.url).join(',');
    }else{
      ruleForm.value.pics=''
    }
  } else if (type == 'pics_ru') {
    if (ruleForm.value.pics_ru) {
      ruleForm.value.pics_ru = list.map(item => item.response ? item.response.info.url : item.url).join(',');
    }else{
      ruleForm.value.pics_ru
    }
  } else if (type == 'pics') {
    if (ruleForm.value.pics) {
      ruleForm.value.pics = list.map(item => item.response ? item.response.info.url : item.url).join(',');
    }else{
      ruleForm.value.pics=''
    }
  }else if (type == 'xq_pics') {
    if (ruleForm.value.xq_pics) {
      ruleForm.value.xq_pics =list.map(item => item.response ? item.response.info.url : item.url).join(',');
    }else{
      ruleForm.value.xq_pics=''
    }
  } else if (type == 'xq_pics_ru') {
    if (ruleForm.value.xq_pics_ru) {
      ruleForm.value.xq_pics_ru = list.map(item => item.response ? item.response.info.url : item.url).join(',');
    }else{
      ruleForm.value.xq_pics_ru=''
    }
  } else if (type == '3D') {
    if (ruleForm.value['3D']) {
      ruleForm.value['3D'] = list.map(item => item.response ? item.response.info.url : item.url).join(',');
    }else{
      ruleForm.value['3D']=''
    }
  } else if (type == 'sd_pic') {
    if (ruleForm.value.sd_pic) {
      ruleForm.value.sd_pic = list.map(item => item.response ? item.response.info.url : item.url).join(',');
    }else{
      ruleForm.value.sd_pic=''
    }
  }
}
//文件回显
const fieldListpics = ref([])
const fieldListpics_ru = ref([])
const fieldListxq_pics = ref([])
const fieldListxq_pics_ru = ref([])
const fieldList3D = ref([])
const fieldListsd_pic = ref([])
const videoList = ref('')
const videoListjj_video = ref('')


watchEffect(() => {
  if (route.query.state != "-1") {
    if (queryId.value) {
      getGoodDetails({ proid: queryId.value }).then((res: any) => {
        console.log(res, '商品详情-------------');
        if (res.code == 1) {
          let { gglist, guigedata, product } = res.data;
          if (product.is_translate === 1) {

          }

          goodhuixian(gglist, guigedata, product)

        }
      }).finally(() => {
        // loading.value = false
      })
    }
  } else {
    //添加商品草稿回显
    getGoodDraft({ is_cg: 1 }).then((res: any) => {
      console.log(res, '草搞');
      if (res.code == 1) {
        let { gglist, guigedata, product } = res.data
        goodhuixian(gglist, guigedata, product)
      }
    }).finally(() => {
      // loading.value = false
    })
  }

})
// 置顶
const onSwitchChangeStatus = async (row: any) => {
  try {
    // loading.value = true;
    let { code } = await topUp({
      // bid: row.bid,
      // id: row.id,
      st: row
    })
    // ElMessage.success(t('common.操作成功'))
    // getTableData()
    // loading.value = false;
  } catch (error) {
    // getTableData()
    // loading.value = false;
    ruleForm.value.zhiding='0'
  }
}
const goodhuixian = (gglist: Array<Object>, guigedata: Array<Object>, product: any) => {
  if (product) {
    // Level1Class.value = Number(product.yj_id) || ''
    ruleForm.value.Level1Class = product.yj_id || ''
    cidhuixian.value = Number(product.cid)//先存一下二级分类等一级分类接口回来了在赋值
    Level1Classchange(product.yj_id)
    let ggname = product[CL('params')]?.split(',') || ""
    ggindex = ggname.length - 1
    for (let index = 0; index < ggname.length; index++) {
      if (index == 0) {
        ggName1.value = ggname[0].split(':')[0]
        ggValue1.value = ggname[0].split(':')[1]
      } else if (index == 1) {
        ggName2.value = ggname[1].split(':')[0]
        ggValue2.value = ggname[1].split(':')[1]
      } else if (index == 2) {
        ggName3.value = ggname[2].split(':')[0]
        ggValue3.value = ggname[2].split(':')[1]
      } else if (index == 3) {
        ggName4.value = ggname[3].split(':')[0]
        ggValue4.value = ggname[3].split(':')[1]
      } else if (index == 4) {
        ggName4.value = ggname[4].split(':')[0]
        ggValue4.value = ggname[4].split(':')[1]
      }
      customizeggList.value.push(index)
    }

    ruleForm.value.name = product[CL('name')]|| ''

    // ruleForm.value.gid = product.gid|| ''
    // ruleForm.value.huodong = product.huodong|| ''
    // ruleForm.value.zhiding = product.zhiding|| ''
    ruleForm.value.sell_price = product[CL('sell_price')] || product.sell_price

    ruleForm.value.pf_price = product.pf_price|| ''
    ruleForm.value.pro_color = product[CL('pro_color')] || ''
    ruleForm.value.sldw = product[CL('sldw')] || ''
    ruleForm.value.weight = product.weight|| ''
    ruleForm.value.currency = product.currency|| ''
    console.log(ruleForm.value.currency,'ruleForm.value.currency')
    ruleForm.value.midu = product.midu || ''
    ruleForm.value.hwlx = product[CL('hwlx')] || ''
    ruleForm.value.limit_start = product.limit_start || ''
    ruleForm.value.pf_price_ru = product.pf_price_ru || ''
    ruleForm.value.levelTwoClass = product.levelTwoClass|| ''
    ruleForm.value.brand = product[CL('brand')] || ''
    ruleForm.value.stock = product.stock|| ''
    ruleForm.value.volume = product.volume || ''
    ruleForm.value.fhdz = product[CL('fhdz')] || ''
    ruleForm.value.is_yf = product.is_yf || 0
    ruleForm.value.sell_price_ru = product.sell_price_ru|| ''
    ruleForm.value.qpsl = product.qpsl|| ''
    ruleForm.value.productSpecifications = product.productSpecifications|| ''
    ruleForm.value.detail =  xqstate.value==3 ? product[CL('detail')] : product[CL('detail')]
    if (product.pics) {
      let array = product.pics.split(",")
      fieldListpics.value = array.map((item: any, index: any) => ({ ['url']: item }));
      ruleForm.value.pics = product.pics
    }
    if (product.pics_ru) {
      let array = product.pics_ru.split(",")
      fieldListpics_ru.value = array.map((item: any, index: any) => ({ ['url']: item }));
      ruleForm.value.pics_ru = product.pics_ru
    }
    if (product.xq_pics) {
      let array = product.xq_pics.split(",")
      fieldListxq_pics.value = array.map((item: any, index: any) => ({ ['url']: item }));
      ruleForm.value.xq_pics = product.xq_pics
    }
    if (product.xq_pics_ru) {
      let array = product.xq_pics_ru.split(",")
      fieldListxq_pics_ru.value = array.map((item: any, index: any) => ({ ['url']: item }));
      ruleForm.value.xq_pics_ru = product.xq_pics_ru
    }
    if (product.sd_pic) {
      let array = product.sd_pic.split(",")
      fieldListsd_pic.value = array.map((item: any, index: any) => ({ ['url']: item }));
      ruleForm.value.sd_pic = product.sd_pic
    }
    if (product['3D']) {
      let array = product['3D'].split(",")
      fieldList3D.value = array.map((item: any, index: any) => ({ ['url']: item }));
      ruleForm.value['3D'] = product['3D']
    }
    videoList.value = product.video
    videoListjj_video.value = product.jj_video
    ruleForm.value.video = product.video
    ruleForm.value.jj_video = product.jj_video
  }
    //查看判断如果没有其他规格数据不显示
  if(xqstate.value==0){
    if(gglist.length==0){
      otherGoodSpecificationssStste.value=false
    }

  }
  if (gglist.length != 0) {
    otherDetailList.value = gglist
  }

}
const options = Array.from({ length: 10000 }).map((_, idx) => ({
  value: `${idx + 1}`,
  label: `${idx + 1}`,
}))
//中文转俄文
const translate = async () => {
  // let res= await getGoodTranslate()
  // console.log(res);

}
const handleInput = async (val) => {
  if(val=='qpsl'){
    let value = ruleForm.value.qpsl;
    // 确保输入的数字不超过最大长度10
    if (value && value.length > 10) {
      ruleForm.value.qpsl = value.slice(0, 10); // 截断超出长度的部分
    }
  }else if(val=='pf_price_ru'){
    let value = ruleForm.value.pf_price_ru;
    // 确保输入的数字不超过最大长度10
    if (value && value.length > 10) {
      ruleForm.value.pf_price_ru = value.slice(0, 10); // 截断超出长度的部分
    }
  }else if(val=='pf_price'){
    let value = ruleForm.value.pf_price;
    // 确保输入的数字不超过最大长度10
    if (value && value.length > 10) {
      ruleForm.value.pf_price = value.slice(0, 10); // 截断超出长度的部分
    }
  }else if(val=='limit_start'){
    let value = ruleForm.value.limit_start;
    // 确保输入的数字不超过最大长度10
    if (value && value.length > 10) {
      ruleForm.value.limit_start = value.slice(0, 10); // 截断超出长度的部分
    }
  }else if(val=='stock'){
    let value = ruleForm.value.stock;
    // 确保输入的数字不超过最大长度8
    if (value && value.length > 8) {
      ruleForm.value.stock = value.slice(0, 8); // 截断超出长度的部分
    }
  }
}
// const handleCheckedCitiesChange = (value: string[]) => {
//   const checkedCount = value.length
//   checkAll.value = checkedCount === cities.length
//   isIndeterminate.value = checkedCount > 0 && checkedCount < cities.length
// }
</script>

<style lang='scss' scoped>
::deep(.el-form-item__content) {
  display: flex !important;
  justify-content: flex-start !important;
}

.reds {
  color: #f56c6c;
  font-size: 14px;
}

.hei {
  width: 200px;
  color: #1D2129;
}

.wenjian {
  width: 150px;
  color: #86909C
}

.title {
  width: 100%;
  height: 30px;
  color: #1D2129;
  // font-family: "PingFang SC";
  font-size: 16px;
  font-style: normal;
  font-weight: 500;
  line-height: normal;
}

.m-right {
  margin-right: 10px;
}

.el-row {
  width: 100%;
  color: #86909C
}

.right-aligned {
  display: flex;
  justify-content: flex-end;
}
.my-el-input-number::after {
  content: '%';
  display: inline-block;
  height: 20px;
  line-height: 20px;
  width: 51px;
  text-align: center;
  position: absolute;
  right: 32px;
  top: 50%;
  font-size: 12px;
  transform: translateY(-50%);
}

.label {
  margin-top: -60px;
  margin-right: 20px;
}

.label2 {
  margin-top: -31px;
  margin-right: 20px;
}

.fix {
  display: flex;
}

.widt120 {
  width: 120px;
  margin-right: 10px;
}

.margin20 {
  margin: 50px 0 !important;
}
</style>
